<!DOCTYPE html>
<html>
<head>
    <link rel="icon" href="/static/images/t_logo.ico" type="image/x-icon"/>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <meta name="referrer" content="no-referrer">
    <!--引入公共样式-->
    <script type="text/javascript" src="common/h-ui/header.js"></script>
    <script src="./js/jquery.min.js" type="text/javascript"></script>
    <script src="./js/requestApi.js" type="text/javascript"></script>
    <style>
        .form-control {
            display: block;
            width: 100%;
            height: 34px;
            padding: 6px 12px;
            font-size: 14px;
            line-height: 1.42857143;
            color: #555;
            background-color: #fff;
            background-image: none;
            border: 1px solid #ccc;
            border-radius: 4px;
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
            -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
            -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
            transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s
        }

        .form-control:focus {
            border-color: #66afe9;
            outline: 0;
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6);
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6)
        }

        .form-control::-moz-placeholder {
            color: #999;
            opacity: 1
        }

        .form-control:-ms-input-placeholder {
            color: #999
        }

        .form-control::-webkit-input-placeholder {
            color: #999
        }

        .form-control::-ms-expand {
            background-color: transparent;
            border: 0
        }

        .form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control {
            background-color: #eee;
            opacity: 1
        }

        .form-control[disabled], fieldset[disabled] .form-control {
            cursor: not-allowed
        }

        textarea.form-control {
            height: auto
        }

        input[type=search] {
            -webkit-appearance: none
        }

        @media screen and (-webkit-min-device-pixel-ratio: 0) {
            input[type=date].form-control, input[type=time].form-control, input[type=datetime-local].form-control, input[type=month].form-control {
                line-height: 34px
            }
        }
    </style>

    <title>图书管理系统</title>
    <meta name="keywords" content="图书管理系统">
    <meta name="description" content="图书管理系统">

</head>
<body>
<header class="navbar-wrapper">
    <div class="navbar navbar-fixed-top">
        <div class="container-fluid cl"><a class="logo navbar-logo f-l mr-10 hidden-xs">图书管理系统</a> <a
                class="logo navbar-logo-m f-l mr-10 visible-xs">library</a>
            <a aria-hidden="false" class="nav-toggle Hui-iconfont visible-xs" href="javascript:;">&#xe667;</a>
            <nav class="nav navbar-nav">
                <ul id="menu1" class="cl">
                    <li class="dropDown dropDown_hover">
                    </li>
                </ul>
            </nav>
            <!--肤色设置-->
            <nav id="Hui-userbar" class="nav navbar-nav navbar-userbar hidden-xs">
                <ul class="cl">
                    <li class="dropDown dropDown_hover">
                        <a id="admin" href="#" class="dropDown_A"> <i class="Hui-iconfont">&#xe6d5;</i></a>
                        <ul class="dropDown-menu menu radius box-shadow">
                            <li><a href="" data-toggle="modal" data-target="#myModal">修改密码</a></li>
<!--                            href="./login/login.html?exit=outLogin"-->
                            <li><a href="javascript:;" id="outLogin">退出</a></li>
                        </ul>
                    </li>
                    <!--<li id="Hui-msg"> <a href="#" title="消息"><span class="badge badge-danger">1</span><i class="Hui-iconfont" style="font-size:18px">&#xe68a;</i></a> </li>-->
                    <li id="Hui-skin" class="dropDown right dropDown_hover">
                        <a href="javascript:;" class="dropDown_A" title="换肤"><i class="Hui-iconfont" style="font-size:18px">&#xe62a;</i></a>
                        <ul class="dropDown-menu menu radius box-shadow">
                            <li><a href="javascript:;" data-val="default" title="默认（黑色）">默认（黑色）</a></li>
                            <li><a href="javascript:;" data-val="blue" title="蓝色">蓝色</a></li>
                            <li><a href="javascript:;" data-val="green" title="绿色">绿色</a></li>
                            <li><a href="javascript:;" data-val="red" title="红色">红色</a></li>
                            <li><a href="javascript:;" data-val="yellow" title="黄色">黄色</a></li>
                            <li><a href="javascript:;" data-val="orange" title="橙色">橙色</a></li>
                            <li><a href="javascript:;" data-val="#00deff" title="白色">白色</a></li>
                        </ul>
                    </li>
                </ul>
            </nav>
        </div>
    </div>
</header>
<aside id="menu23" class="Hui-aside">

</aside>
<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a>
</div>
<section class="Hui-article-box">
    <div id="Hui-tabNav" class="Hui-tabNav hidden-xs">
        <div class="Hui-tabNav-wp">
            <ul id="min_title_list" class="acrossTab cl">
                <li class="active">
                    <span title="数据全貌" data-href="welcome.html">数据全貌</span>
                    <i></i>
                    <em></em>
                </li>
            </ul>
        </div>
        <div class="Hui-tabNav-more btn-group"><a id="js-tabNav-prev" class="btn radius btn-default size-S"
                                                  href="javascript:;"><i class="Hui-iconfont">&#xe6d4;</i></a><a
                id="js-tabNav-next" class="btn radius btn-default size-S" href="javascript:;"><i class="Hui-iconfont">&#xe6d7;</i></a>
        </div>
    </div>
    <div id="iframe_box" class="Hui-article">
        <div class="show_iframe">
            <div style="display:none" class="loading"></div>

        </div>
    </div>
</section>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
     style="margin-top: 100px">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    修改密码
                </h4>
            </div>
            <div class="modal-body">
                <div class="form-group" style="width: 300px; margin-left: 90px">
                    <label class="col-sm-2 control-label" style="width: 100px;padding: 15px">原密码</label>
                    <div class="col-sm-10">
                        <input type="password" class="form-control	" id="oldPassword"
                               placeholder="请输入原密码" style="width: 300px;" autocomplete="off" >
                    </div>
                </div>
                <div class="form-group" style="width: 300px; margin-left: 90px">
                    <label class="col-sm-2 control-label" style="width: 100px;padding: 15px">新密码</label>
                    <div class="col-sm-10">
                        <input type="password" class="form-control" id="newPassword"
                               placeholder="请输入新密码" style="width: 300px;" onblur="newPassword()" autocomplete="off">
                    </div>
                </div>
                <div class="form-group" style="width: 300px; margin-left: 90px;padding-bottom: 15px">
                    <label class="col-sm-2 control-label" style="width: 100px;padding: 15px">确认密码</label>
                    <div class="col-sm-10">
                        <input type="password" class="form-control" id="reNewPassword"
                               placeholder="请确认新密码" style="width: 300px;" onblur="reNewPassword()" autocomplete="off">
                    </div>
                </div>
                <div class="form-group" style="width: 300px; margin-left: 105px;padding-bottom: 15px">
                    <span style="color:red;">请输入8-20位密码由大小写字母、数字组成</span>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" onclick="updatePassword()" class="btn btn-primary">
                    提交更改
                </button>
                <button type="button" class="btn btn-default"
                        data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="contextMenu" id="Huiadminmenu">
    <ul>
        <li id="closethis">关闭当前</li>
        <li id="closeall">关闭全部</li>
    </ul>
</div>
<script src="h-ui/js/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery.md5.js"></script>
<script type="text/javascript">
    //从头部取得用户名
    $("#admin").text(localStorage.getItem('userName'));

    function loginEnd(json) {
        if (json.code != 0) {
            alert(json.msg);
            window.location.href = "/index.html";
        }
    }

    function newPassword() {
        var oldPassword = $("#oldPassword").val();
        var newPassword = $("#newPassword").val();
        if (newPassword != "") {
            if (oldPassword == newPassword) {
                alert("新密码和旧密码一致，请重新输入");
            }
        }
    }

    function reNewPassword() {
        var newPassword = $("#newPassword").val();
        var reNewPassword = $("#reNewPassword").val();
        if (reNewPassword != "") {
            if (reNewPassword != newPassword) {
                alert("确认密码和新密码不一致，请重新输入");
            }
        }
    }

    //修改密码
    function updatePassword() {
        var oldPassword = $("#oldPassword").val();
        var newPassword = $("#newPassword").val();
        var reNewPassword = $("#reNewPassword").val();
        if (oldPassword == "") {
            layer.msg("原密码不能为空");
        } else if (newPassword == "") {
            layer.msg("新密码不能为空")
        } else if (reNewPassword == "") {
            layer.msg("确认密码不能为空")
        } else if (newPassword != reNewPassword) {
            layer.msg("确认密码和新密码不一致，请重新输入")
        } else {
            let regex = /^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{8,20}$/;//校验密码规则
            if (!regex.test(newPassword)) {
                alert("密码必须是8-20位密码由大小写字母、数字组成");
                return;
            }
            var data = {"oldPwd": $.md5($("#oldPassword").val()), "newPwd": $.md5($("#newPassword").val())}
            requestApi("user/changePwd", data, "POST", changePwd);
        }
    };

    //修改密码之后的提示
    function changePwd(json) {
        if (json.data == true) {
            alert("修改成功！请重新登录");
            outLoginMethod();
            window.location.href = "./login/login.html?exit=outLogin";
        } else {
            alert(json.msg);
        }
    }

    // setInterval(function () {
    //     requestApi("chkLogin", {}, "POST", loginEnd);
    // }, 600000);

    requestApiTB("getAllMenu", {}, "POST", getMenu);

    function getMenu(json) {
        if (json.code != 0) {
            alert(json.msg);
            if (json.code == 7004) {
                window.location.href = "/index.html";
            }
        } else {
            $("#menu1").html("");//一级菜单
            $("#menu23").html("");//二级菜单

            var data = json.data;//数据格式
            var menu23html = "";//内容
            for (var i = 0; i < data.length; i++) {//横向
                $("#menu1").append("<li class=\"navbar-levelone " + (i == 0 ? "current" : "") + "\"><a href=\"javascript:;\"><strong>" + data[i].title + "</strong></a></li>");
                menu23html += "<div class=\"menu_dropdown bk_2\">";
                var data2 = data[i].list;
                for (var i2 = 0; i2 < data2.length; i2++) {
                    if (data2[i2].list.length == 0 && data2[i2].url) {//判断有没有子级并且当前有url
                        //js的模板字符串
                        let hrefCustomer = data2[i2].isOpenNewWindow == 1 ? 'onclick="jumpToUrl(\'' + data2[i2].url + '\')"' : 'href="javascript:void(0)"';
                        menu23html += `
							<dl id="menu-${i}-${i2}">
								<a data-href="${data2[i2].url}" data-title="${data2[i2].title}" ${hrefCustomer}>
									<dt>
										<i class="Hui-iconfont">${data2[i2].icoCode}</i>
										${data2[i2].title}
									</dt>
								</a>
								<dd>
							<ul>
						`
                    } else {//如果有子级
                        menu23html += `<dl id="menu-${i}-${i2}"><dt><i class="Hui-iconfont">${data2[i2].icoCode}</i>${data2[i2].title}<i class="Hui-iconfont menu_dropdown-arrow">&#xe6d5;</i></dt><dd><ul>`
                        var data3 = data2[i2].list;
                        //里面的标题点击时可打开新窗口
                        for (var i3 = 0; i3 < data3.length; i3++) {
                            if (data3[i3].isOpenNewWindow == 1) {
                                menu23html += `<li>
                                                    <a data-href="${data3[i3].url}" data-title="${data[i3].title}" onclick="jumpToUrl('${data3[i3].url}')"
                                                    href="javascript:void(0)">${data3[i3].title}
                                                    </a>
                                               </li>
                                              `
                            } else {
                                menu23html += `<li><a data-href="${data3[i3].url}" data-title="${data3[i3].title}" href="javascript:void(0)">${data3[i3].title}</a></li>`
                            }
                        }
                    }
                    menu23html += "</ul></dd></dl>";
                }
                menu23html += "</div>";
            }
            $("#menu23").append(menu23html);
        }
    }


    function jumpToUrl(url) {
        if (url) {

            window.open(url, '_blank');

        }
    }

    function outLoginMethod(){
        requestApiTB("login/outLogin", {}, "POST", function(res){
        });
    }

    $(function () {
        $("#outLogin").click(function(){
            window.location.href = './login/login.html';//跳转到首页
            outLoginMethod();
        })
    })
</script>

<script type="text/javascript" src="common/h-ui/footer.js"></script>
<script type="text/javascript">
    $(function () {

        $("body").Huitab({
            tabBar: ".navbar-wrapper .navbar-levelone",
            tabCon: ".Hui-aside .menu_dropdown",
            className: "current",
            index: 0,
        });
    });

</script>
</body>
</html>